<body>
    <script>
        var arr = [1,2,3,4,5,6,7]
        console.log(arr)

        // arr[0]=arr[1]  //1
        // arr[1]=arr[2]  //2
        // arr[2]=arr[3]  //3
        // arr[3]=arr[4]  //4
        // arr[4]=arr[5]  //5
        // arr[5]=arr[6]  //6


         function fun(arr,n){

          for(var i= n;i<arr.length;i++){
            
            arr[i] = arr[i+1]

          }
          return arr.length = arr.length-1

         }
        
         console.log(fun(arr,2))
         console.log(arr)

    </script>
</body>